package com.mjh.zhujianju.controller.base;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.livew.framework.pojo.AjaxResult;
import com.livew.framework.utils.XTStringUtils;
import com.mjh.zhujianju.model.base.AreasEO;
import com.mjh.zhujianju.service.base.AreasService;

@RestController
@RequestMapping("area")
public class AreasController {

	@Resource
	private AreasService areasService;
	
	
	
	
	
	
	/**
	 * 
	 * @param code
	 * @return
	 */
	@RequestMapping(value="getDefualtCity",method=RequestMethod.POST)
	public AjaxResult getDefualtCity(AreasEO area) {
		String code="42";//默认
	 if(area!=null&&!XTStringUtils.isEmpty(area.getCode())) {
		 code = area.getCode();
	 }
	List<AreasEO> areas = areasService.getListByParentCode(code);
	return AjaxResult.getResult(areas);
	}
	
	/**
	 * 
	 * @param code
	 * @return
	 */
	@RequestMapping(value="getChildList/{code}",method=RequestMethod.GET)
	public AjaxResult getDefualtCity(@PathVariable("code")String code) {
		List<AreasEO> areas = areasService.getListByCode(code);
		return AjaxResult.getResult(areas);
	}
	
	/**
	 * 
	 * @param code
	 * @return
	 */
	@RequestMapping(value="getSiblingListByCode/{code}",method=RequestMethod.GET)
	public AjaxResult getSiblingListByCode(@PathVariable("code")String code) {
		List<AreasEO> areas = areasService.getSiblingListByCode(code);
		return AjaxResult.getResult(areas);
	}
	
	
	/**
	 * 
	 * @param code
	 * @return
	 */
	@RequestMapping(value="getProvinceList",method=RequestMethod.GET)
	public AjaxResult getProvinceList() {
		List<AreasEO> areas = areasService.getProvinceList();
		return AjaxResult.getResult(areas);
	}
	
	
	
	
	
}
